﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T05
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("输入项数：");
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("圆周率的近似值：{0}", Sum(n));
            Console.ReadKey();

        }
        static double Sum(int n)
        {
            double k=0,a=1.0;
            for(double i=0;i<n;i++)
            {

                k += a / (2 * i + 1);
                     a = -a;
            }
            return 4*k;
        }
    }
}
